home *** CD-ROM | disk | FTP | other *** search
- VERSION 5.00
- Object = "{335C3C4F-E3F2-11D0-87E8-00A0C903B29D}#5.0#0"; "VCFI5.OCX"
- Begin VB.Form Form1
- Caption = "Form1"
- ClientHeight = 6315
- ClientLeft = 3495
- ClientTop = 2190
- ClientWidth = 9015
- LinkTopic = "Form1"
- PaletteMode = 1 'UseZOrder
- ScaleHeight = 6315
- ScaleWidth = 9015
- Begin VB.Frame Frame1
- Caption = " Text Metrics "
- Height = 795
- Index = 3
- Left = 5640
- TabIndex = 1
- Top = 3420
- Width = 2655
- End
- Begin VB.Frame Frame1
- Caption = " Chart Formatting "
- Height = 795
- Index = 1
- Left = 5640
- TabIndex = 6
- Top = 4320
- Width = 2655
- End
- Begin VB.Frame Frame1
- Caption = " Draw To: "
- Height = 795
- Index = 0
- Left = 5640
- TabIndex = 3
- Top = 5220
- Width = 2655
- Begin VB.CommandButton cmdPicture
- Caption = "Picture"
- Height = 375
- Left = 180
- MousePointer = 1 'Arrow
- TabIndex = 5
- Top = 300
- Width = 915
- End
- Begin VB.CommandButton cmdPrinter
- Caption = "Printer"
- Height = 375
- Left = 1200
- TabIndex = 4
- Top = 300
- Width = 915
- End
- End
- Begin VB.PictureBox Picture1
- Appearance = 0 'Flat
- AutoRedraw = -1 'True
- BackColor = &H80000005&
- ClipControls = 0 'False
- ForeColor = &H80000008&
- Height = 3195
- Left = 5580
- ScaleHeight = 3165
- ScaleWidth = 3225
- TabIndex = 2
- Top = 60
- Width = 3255
- End
- Begin VtChartLib.VtChart VtChart1
- Height = 6195
- Left = 60
- TabIndex = 0
- Top = 0
- Width = 5355
- _ExtentX = 9446
- _ExtentY = 10927
- _0 = $"Chdraw.frx":0000
- _1 = $"Chdraw.frx":0405
- _2 = $"Chdraw.frx":080A
- _3 = $"Chdraw.frx":0C0F
- _4 = $"Chdraw.frx":1014
- _5 = $"Chdraw.frx":1419
- _6 = $"Chdraw.frx":181E
- _7 = $"Chdraw.frx":1C23
- _8 = $"Chdraw.frx":2028
- _9 = $"Chdraw.frx":242D
- _10 = $"Chdraw.frx":2832
- _11 = $"Chdraw.frx":2C37
- _12 = $"Chdraw.frx":303C
- _13 = $"Chdraw.frx":3441
- _14 = $"Chdraw.frx":3846
- _count = 15
- _ver = 1
- End
- Attribute VB_Name = "Form1"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- Private Sub chkLayout_Click(Value As Integer)
- ' Scaled is only used if Layout is False
- chkStretch.Enabled = Not (chkLayout.Value)
- End Sub
- Private Sub cmdPicture_Click()
- On Error GoTo DrawPictureError
- Dim top%, left%, bottom%, right%
- ' Set the destination to the entire picture box.
- ' Convert from twips (default) to pixels with the
- ' Screen.TwipsPerPixelX property. Note that you can
- ' suffer roundoff error here so you may want to pad
- ' the width and height.
- top = Picture1.ScaleTop / Screen.TwipsPerPixelY
- left = Picture1.ScaleLeft / Screen.TwipsPerPixelX
- bottom = Picture1.ScaleHeight / Screen.TwipsPerPixelY + 2
- right = Picture1.ScaleWidth / Screen.TwipsPerPixelX + 2
- ' Clear out the old image
- Picture1.Cls
- ' Use the check boxes for args so we can readily see how
- ' each possiblity affects the image.
- VtChart1.Draw Picture1.hDC, VtDcTypeDisplay, top, left, _
- bottom, right, True, True
- 'VtChart1.Draw
- Exit Sub
- DrawPictureError:
- MsgBox Error
- End Sub
- Private Sub Command1_Click()
- On Error GoTo DrawPrinterError
- Dim top%, left%, bottom%, right%
- Dim titleWidth&, titleHeight&
- With Printer
- ' Set the font and position a title on the page.
- ' The chart already has a title -
- ' this title is text drawn directly on the object.
- .FontSize = 48
- .FontName = "Times New Roman"
- .FontUnderline = True
- titleWidth = .TextWidth("VtChDraw Example")
- titleHeight = .TextHeight("VtChDraw Example")
-
- ' Center the text and move it down off the top margin
- .CurrentX = .ScaleLeft + (.ScaleWidth - titleWidth) / 2
- .CurrentY = 0.3 * titleHeight
- ' Draw the text on the hDC
- Printer.Print "VtChDraw Example"
-
- ' Bounding rect for the chart. Place below Title and conert from twips to pixels.
- top = (.ScaleTop + titleHeight) / .TwipsPerPixelY
- left = .ScaleLeft / .TwipsPerPixelX
- bottom = .ScaleHeight / .TwipsPerPixelY
- right = .ScaleWidth / .TwipsPerPixelX
-
- ' Draw the chart on the hDC using the option check boxes
- ' as arguments
- VtChart1.Draw Picture1.hDC, VtDcTypeDisplay, top, left, _
- bottom, right, chkLayout.Value, chkStretch.Value
-
- ' Use these to adjust the line drawings
- '.DrawMode =
- '.DrawStyle =
- '.DrawWidth =
- '.ForeColor =
-
- ' Draw a bounding box
- Printer.Line (.ScaleLeft, .ScaleTop)-(.ScaleWidth, .ScaleTop)
- Printer.Line (.ScaleWidth - 5, .ScaleTop)-(.ScaleWidth - 5, .ScaleHeight)
- Printer.Line (.ScaleWidth - 5, .ScaleHeight - 5)-(.ScaleLeft, .ScaleHeight - 5)
- Printer.Line (.ScaleLeft, .ScaleHeight - 5)-(.ScaleLeft, .ScaleTop)
-
- ' Feed a page and then flush it through the
- .NewPage
- .EndDoc
- End With
- Exit Sub
- DrawPrinterError:
- MsgBox Error
- End Sub
- Private Sub Command2_Click()
- On Error GoTo DrawPictureError
- Dim top%, left%, bottom%, right%
- ' Set the destination to the entire picture box.
- ' Convert from twips (default) to pixels with the
- ' Screen.TwipsPerPixelX property. Note that you can
- ' suffer roundoff error here so you may want to pad
- ' the width and height.
- top = Picture1.ScaleTop / Screen.TwipsPerPixelY
- left = Picture1.ScaleLeft / Screen.TwipsPerPixelX
- bottom = Picture1.ScaleHeight / Screen.TwipsPerPixelY + 2
- right = Picture1.ScaleWidth / Screen.TwipsPerPixelX + 2
- ' Clear out the old image
- Picture1.Cls
- ' Use the check boxes for args so we can readily see how
- ' each possiblity affects the image.
- VtChart1.Draw Picture1.hDC, VtDcTypeDisplay, top, left, _
- bottom, right, chkLayout.Value, chkStretch.Value
-
- Exit Sub
- DrawPictureError:
- MsgBox Error
- End Sub
- Private Sub cmdPrinter_Click()
- On Error GoTo DrawPrinterError
- Dim top%, left%, bottom%, right%
- Dim titleWidth&, titleHeight&
- With Printer
- ' Set the font and position a title on the page.
- ' The chart already has a title -
- ' this title is text drawn directly on the object.
- .FontSize = 48
- .FontName = "Times New Roman"
- .FontUnderline = True
- titleWidth = .TextWidth("VtChDraw Example")
- titleHeight = .TextHeight("VtChDraw Example")
-
- ' Center the text and move it down off the top margin
- .CurrentX = .ScaleLeft + (.ScaleWidth - titleWidth) / 2
- .CurrentY = 0.3 * titleHeight
- ' Draw the text on the hDC
- Printer.Print "VtChDraw Example"
-
- ' Bounding rect for the chart. Place below Title and conert from twips to pixels.
- top = (.ScaleTop + titleHeight) / .TwipsPerPixelY
- left = .ScaleLeft / .TwipsPerPixelX
- bottom = .ScaleHeight / .TwipsPerPixelY
- right = .ScaleWidth / .TwipsPerPixelX
-
- ' Draw the chart on the hDC using the option check boxes
- ' as arguments
- VtChart1.Draw Printer.hDC, VtDcTypeDisplay, top, left, _
- bottom, right, False, True
-
- ' Use these to adjust the line drawings
- '.DrawMode =
- '.DrawStyle =
- '.DrawWidth =
- '.ForeColor =
-
- ' Draw a bounding box
- Printer.Line (.ScaleLeft, .ScaleTop)-(.ScaleWidth, .ScaleTop)
- Printer.Line (.ScaleWidth - 5, .ScaleTop)-(.ScaleWidth - 5, .ScaleHeight)
- Printer.Line (.ScaleWidth - 5, .ScaleHeight - 5)-(.ScaleLeft, .ScaleHeight - 5)
- Printer.Line (.ScaleLeft, .ScaleHeight - 5)-(.ScaleLeft, .ScaleTop)
-
- ' Feed a page and then flush it through the
- .NewPage
- .EndDoc
- End With
- Exit Sub
- DrawPrinterError:
- MsgBox Error
- End Sub
- Private Sub Form_Load()
- ' Put the form in the top left corner
- Form1.left = 0
- Form1.top = 0
- 'pnlControls.top = 60
- VtChart1.top = 120
- End Sub
- Private Sub Form1_Click()
- End Sub
- Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
- End
- End Sub
- Private Sub Form_Resize()
- VtChart1.Repaint = False
- If ScaleHeight > 7200 Then
- 'pnlControls.Height = ScaleHeight - 135
- VtChart1.Height = ScaleHeight - 255
- End If
- If ScaleWidth > 4000 Then
- 'pnlControls.left = ScaleWidth - pnlControls.Width - 60
- 'VtChart1.Width = pnlControls.left - 235
- End If
- VtChart1.Repaint = True
- End Sub
- Private Sub optTextMetrics_Click(Index As Integer, Value As Integer)
- '' Screen and printer text metrics are different. If you
- '' draw to the screen, you will want to use virtual metrics
- '' (defined by the TrueType font). Otherwise use the device
- '' type which is optimized for your output device.
- If Value Then
- Select Case Index
- Case 0
- VtChart1.TextLengthType = VtTextLengthTypeVirtual
- Case 1
- VtChart1.TextLengthType = VtTextLengthTypeDevice
- End Select
- End If
- End Sub
-